package com.andyliu.controller;

import com.andyliu.common.ResponseResult;
import com.andyliu.util.MybatisGenUtil;
import com.andyliu.util.StringUtil;
import com.andyliu.vo.PageVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @packageName: com.andyliu.controller
 * @user: andyliu
 * @date: 2021/8/4 18:13
 * @email 115176513@qq.com
 * @description: TODO
 */
public class BaseController {

    public PageVO startPage(){
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        ServletRequestAttributes requestAttributes1 = (ServletRequestAttributes)requestAttributes;
        String pageNumber = requestAttributes1.getRequest().getParameter("pageNumber");
        String pageSize = requestAttributes1.getRequest().getParameter("pageSize");
        PageVO pageVO = new PageVO();
        if(StringUtils.isNotEmpty(pageNumber)){
            pageVO.setPageNumber(Integer.parseInt(pageNumber));
        }
        if(StringUtils.isNotEmpty(pageSize)){
            pageVO.setPageSize(Integer.parseInt(pageSize));
        }
        return pageVO;
    }

}


